home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Everything / CRadios.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  5.1 KB  |  235 lines  |  [TEXT/CWIE]

  1. // CRadios.cp -- window methods
  2.  
  3. #include "CRadios.h"
  4.  
  5. #include <UEnvironment.h>
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LTabGroup.h>
  10. #include <LRadioGroupView.h>
  11. #include <LRadioButton.h>
  12. #include <LAMControlImp.h>
  13. #include <LGARadioButtonImp.h>
  14. #include <LTextGroupBox.h>
  15. #include <LAMControlViewImp.h>
  16. #include <LGATextGroupBoxImp.h>
  17. #include <CustomControls.h>
  18. #include <LBevelButton.h>
  19. #include <LAMBevelButtonImp.h>
  20. #include <LGABevelButtonImp.h>
  21. #include <LTextButton.h>
  22. #include <CTextUtils.h>
  23.  
  24. #include "DDocData.h"
  25. #include "DModalCheckboxesData.h"
  26. #include "DModalRadiosData.h"
  27. #include "DModalTextData.h"
  28. #include "DModalStuffData.h"
  29. #include "DModalBarsData.h"
  30. #include "DModelessCheckboxesData.h"
  31. #include "DModelessRadiosData.h"
  32. #include "DModelessTextData.h"
  33. #include "DModelessStuffData.h"
  34. #include "DModelessBarsData.h"
  35. #include "EverythingCmds.h"
  36.  
  37.  
  38. #define PPob_RadiosID    203
  39. #define RidL_RadiosID    203
  40.  
  41. Boolean        CRadios::sIsRegistered = false;
  42.  
  43. //----------
  44. CRadios*        CRadios::CreateRadios (
  45.     LCommander*        inSuperCommander,
  46.     DDocData*        inData)
  47. {
  48.     if (!sIsRegistered) {
  49.         RegisterClass ();
  50.     }
  51.  
  52.     CRadios*        window;
  53.     window = (CRadios *)LWindow::CreateWindow(PPob_RadiosID, inSuperCommander);
  54.     window->ConnectToData (inData);
  55.     return window;
  56. }
  57.  
  58. //----------
  59. #define    RegisterClasses(AbstractClass,AMImpClass,GAImpClass)    \
  60.     RegisterClass_(AbstractClass);    \
  61.     if (useAppearance) {    \
  62.         RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID);    \
  63.     } else {    \
  64.         RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID);    \
  65.     }
  66.  
  67. //----------
  68. void    CRadios::RegisterClass ()
  69. {
  70.     Boolean        useAppearance = UEnvironment::HasFeature (env_HasAppearance);
  71.  
  72.     RegisterClass_(CRadios);
  73.  
  74.     // register the pane classes we use
  75.     RegisterClass_(LRadioGroupView);
  76.     RegisterClasses (LRadioButton, LAMControlImp, LGARadioButtonImp);
  77.     RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
  78.     RegisterClasses (CRadioButton, CustomControlImp, CustomControlImp);
  79.     RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
  80.     RegisterClass_(LTextButton);
  81.  
  82.     sIsRegistered = true;
  83. }
  84.  
  85. //----------
  86. CRadios::CRadios (
  87.     LStream*    inStream)
  88.     : LWindow (inStream)
  89. {
  90. }
  91.  
  92. //----------
  93. CRadios::~CRadios ()
  94. {
  95. }
  96.  
  97. //----------
  98. //    This member function gets called once the containment hierarchy that contains
  99. //    this pane has been built. It gives us a chance to get data members for
  100. //    interesting subviews, and to do other operations now that our subviews exist.
  101. void    CRadios::FinishCreateSelf ()
  102. {
  103.     mRadioGroupGroup = (LRadioGroupView*) FindPaneByID ('Radp');
  104.  
  105.     mStandardRadio = (LRadioButton*) FindPaneByID ('Stad');
  106.  
  107.     mGroupGroup = (LRadioGroupView*) FindPaneByID ('Grop');
  108.  
  109.     mGraphicGroup = (LRadioGroupView*) FindPaneByID ('Grac');
  110.  
  111.     mStopRadio = (CRadioButton*) FindPaneByID ('Stop');
  112.  
  113.     mGoRadio = (CRadioButton*) FindPaneByID ('Go  ');
  114.  
  115.     mBevelGroup = (LRadioGroupView*) FindPaneByID ('Bevl');
  116.  
  117.     mRadioButtonRadio = (LBevelButton*) FindPaneByID ('Radn');
  118.  
  119.     mRadioButton2Radio = (LBevelButton*) FindPaneByID ('Rad2');
  120.  
  121.     mTextGroup = (LRadioGroupView*) FindPaneByID ('Text');
  122.  
  123.     mNameRadio = (LTextButton*) FindPaneByID ('Name');
  124.  
  125.     mKindRadio = (LTextButton*) FindPaneByID ('Kind');
  126.  
  127.     mSizeRadio = (LTextButton*) FindPaneByID ('Size');
  128.  
  129.  
  130.     UReanimator::LinkListenerToControls(this, this, RidL_RadiosID);
  131.         // "connect" self to our controls that we want to "listen" to
  132.  
  133.     // any additional initialization for your window:
  134. }
  135.  
  136. //----------
  137. void    CRadios::ConnectToData (
  138.     DDocData*        inData)
  139. {
  140.     mData = inData;
  141.     mData->AddListener (this);
  142.  
  143.     mRadioGroupGroup->SetValue (mData->GetRadioGroup ());
  144.     mGroupGroup->SetValue (mData->GetGroup ());
  145.     mGraphicGroup->SetValue (mData->GetGraphic ());
  146.     mBevelGroup->SetValue (mData->GetBevel ());
  147.     mTextGroup->SetValue (mData->GetText ());
  148. }
  149.  
  150. //----------
  151. void    CRadios::DataChanged (
  152.     long        inDataID)
  153. {
  154.     StopListening ();
  155.  
  156.     if (inDataID == idRadioGroup) {
  157.         mRadioGroupGroup->SetValue (mData->GetRadioGroup ());
  158.     }
  159.     if (inDataID == idGroup) {
  160.         mGroupGroup->SetValue (mData->GetGroup ());
  161.     }
  162.     if (inDataID == idGraphic) {
  163.         mGraphicGroup->SetValue (mData->GetGraphic ());
  164.     }
  165.     if (inDataID == idBevel) {
  166.         mBevelGroup->SetValue (mData->GetBevel ());
  167.     }
  168.     if (inDataID == idText) {
  169.         mTextGroup->SetValue (mData->GetText ());
  170.     }
  171.  
  172.     StartListening ();
  173. }
  174.  
  175. //----------
  176. void    CRadios::ListenToMessage (
  177.     MessageT    inMessage,
  178.     void*        ioParam)
  179. {
  180.     switch (inMessage) {
  181.     case msgDataChanged:
  182.             DataChanged ((long)ioParam);
  183.         break;
  184.  
  185.     default:
  186.           ; // do something
  187.         break;
  188.     }
  189. }
  190.  
  191. //----------
  192. Boolean        CRadios::ObeyCommand (
  193.     CommandT    inCommand,
  194.     void*        ioParam)
  195. {
  196.     Boolean        cmdHandled = true;
  197.  
  198.     if (inCommand < 0) {
  199.         // modal dialog has finished
  200.  
  201.         switch (-inCommand) {
  202.         }
  203.  
  204.     } else {
  205.         switch (inCommand) {
  206.  
  207.         default:
  208.                 cmdHandled = LWindow::ObeyCommand(inCommand, ioParam);
  209.             break;
  210.         }
  211.     }
  212.  
  213.     return cmdHandled;
  214. }
  215.  
  216. //----------
  217. void    CRadios::FindCommandStatus (
  218.     CommandT    inCommand,
  219.     Boolean        &outEnabled,
  220.     Boolean        &outUsesMark,
  221.     Char16        &outMark,
  222.     Str255        outName)
  223. {
  224.     outUsesMark = false;
  225.  
  226.     switch (inCommand) {
  227.  
  228.  
  229.     default:
  230.             LWindow::FindCommandStatus(inCommand, outEnabled,
  231.                                         outUsesMark, outMark, outName);
  232.         break;
  233.     }
  234. }
  235.